package com.esri.core.internal;

import android.content.Context;
import android.os.Build;
import com.esri.core.internal.io.handler.c;
import com.esri.core.internal.util.f;
import com.esri.core.internal.util.h;
import com.esri.core.symbol.SymbolHelper;
import java.io.File;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;

/* loaded from: classes.dex */
public class RuntimeHelper {
    private static final AtomicBoolean a = new AtomicBoolean(false);
    private static final String b = "runtimecore_java";

    public static final void initialize() {
        if (a.compareAndSet(false, true)) {
            a();
            b();
            c();
        }
    }

    public static final File a(Context context) {
        if (Build.VERSION.SDK_INT < 8) {
            return null;
        }
        File externalCacheDir = context.getExternalCacheDir();
        if (externalCacheDir == null) {
            return context.getCacheDir();
        }
        if (!externalCacheDir.exists()) {
            externalCacheDir.mkdirs();
        }
        return externalCacheDir;
    }

    private static final void a() {
        System.loadLibrary(b);
    }

    private static void b() {
        h.a(new SymbolHelper());
    }

    private static void c() {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(f.c);
        stringBuffer.append("/");
        stringBuffer.append(Build.VERSION.RELEASE);
        stringBuffer.append("/");
        stringBuffer.append(d().replace(' ', '-'));
        c.a(stringBuffer.toString());
    }

    private static String d() {
        String str = Build.MANUFACTURER;
        String str2 = Build.MODEL;
        if (str2 != null && str2.startsWith(str)) {
            return str2.toUpperCase(Locale.US);
        }
        return (str + "-" + str2).toUpperCase(Locale.US);
    }
}
